<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'uploadImage.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  <body>
	
	<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
	<!-- <script type="text/javascript" src="js/jquery.js"></script>
		<script>
				$(document).ready(function(){
				
					$("#upload").click(function(){
					alert(123);
					var fileObj = document.getElementById("file").files[0];
					$.ajax({
					url:"https://api-cn.faceplusplus.com/facepp/v3/detect",
					type:"post",
					data:{
						"api_key":"fPH4nB1gdFW6qts4Flzdgb5jgGtIIJIR",
						"api_secret":"4T-2jBOZOE6nvCsv7YkAuiCaeGwEopOT",
						"image_file":fileObj,
						"return_landmark":"1",
						"return_attributes":"none"
					},
					 success: function(e){
					 	console.log(e.data);
					 },
					 error:function(e){
					 	console.log(e.data);
					 }
				});
					});
				});
		</script> -->
		<script type="text/javascript">
				function upload(){
					var fileObj = document.getElementById("file").files[0];
					alert('123');
					var form = new FormData();
					form.append("api_key", "fPH4nB1gdFW6qts4Flzdgb5jgGtIIJIR");
					form.append("api_secret", "4T-2jBOZOE6nvCsv7YkAuiCaeGwEopOT");
					form.append("image_file", fileObj);
					var settings = {
					  "async": true,
					  "crossDomain": true,
					  "url": "https://api-cn.faceplusplus.com/facepp/v3/detect",
					  "method": "POST",
					  "headers": {
					  "cache-control": "no-cache"
					  //"postman-token": "da1d2da2-1118-20f5-31d7-5cabede03667"
					  },
					  "processData": false,
					  "contentType": false,
					  "mimeType": "multipart/form-data",
					  "data": form
					};
					$.ajax(settings).done(function (response) {
					  console.log(response);
					});
				}
		</script>
		
					
  </head>
    <input type="file" id="file" name="img1"><br/>
    <input type="button" value="上传" id="upload" onclick="upload();">
  </body>
</html>
